# -*-coding:utf-8-*-

import cookielib, threading, random, paramiko, time
import logConfig as log
from protocol import *
from threadCenter import *
from interfaceFunc import *

# 函数接口：压力测试操作入口
def PT_testInterface(testInterface, cpu, num):
    startNum = 10001
    endNum = startNum + num -1
    if testInterface == 'company_createUser':
        PT_company_createUser_single('autoTest1', '123456', 'aoTest', 10001, 11000, 1)
    elif testInterface == 'company_deleteUser':
        PT_company_deleteUser_single('autoTest1', '123456', 'aoTest', 40001, 41010)
    elif testInterface == 'intercom_httpSoftwareQuery':
        PT_intercom_httpSoftwareQuery(cpu, num)
    elif testInterface == 'intercom_httpLogin':
        PT_intercom_httpLogin(cpu, 'aoTest', '123456', startNum, endNum)
    elif testInterface == 'intercom_httpGetGroupQuery':
        PT_intercom_httpGroupQuery(cpu, 'aoTest', '123456', startNum, endNum)
    elif testInterface == 'intercom_httpGetAllGroupMember':
        PT_intercom_httpGetAllGroupMember(cpu, 'aoTest', '123456', startNum, endNum)
    elif testInterface == 'intercom_inVoiceChannel':
        PT_intercom_inVoiceChannel(cpu, 'aoTest', '123456', startNum, endNum)
    elif testInterface == 'getOnlineNumMax':
        PT_getOnlineNumMax(cpu, 'aoTest', '123456', num)
    else:
        pass

# 测试平台：运营管理平台
# 调用方式：单线程
# 测试接口：创建用户、删除用户
# 创建用户流程# step1:企业账号登录 step2:增加用户
# 删除用户流程# Step1:企业账号登录 Step2:请求账号列表界面，过滤出对应ID step3:调用接口删除对应ID对应的用户
def PT_company_createUser_single(cpu, companyAccount, companyCode, companyPassword, startNum, endNum, userType):
    log.info(u"开始批量创建企业用户...")
    lock = threading.Lock()

    serverIP = cpu["data"]._const["HTTP"]["HOST"]
    groupArraySting = ""
    defaultGroup = 0
    serial = 0
    # 登录后cookie的信息存储，用于携带cookie信息到服务端，然后服务端会在cookie中存入JSESSIONID并返回
    cookies     = cookielib.CookieJar()
    cookies.set_cookie(make_cookie("fnRemeberAdminCode", "true", serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminCode", companyAccount, serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminPassword",  companyPassword, serverIP+'/company/'))
    opener      = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
    urllib2.install_opener(opener)
    # 发起登录请求
    startTime_1 = time.time()
    response    = FormHttpPostFirst_returnData('http://'+serverIP+'/company/login.do', {'adminCode': companyAccount, 'password': companyPassword})
    endTime_1   = time.time()
    useTime_1   = endTime_1 - startTime_1
    if response["status"] == 100:
        response = FormHttpGet_returnData('http://' + serverIP + '/company/companyGroupEditPage_query.do?timeStamp=' + str(getTimestamp()), {})
        if response["status"] == 100:
            data = response["data"]
            groupArray = []
            for group in data:
                if defaultGroup == 0:
                    defaultGroup = group["groupId"]
                groupArray.append(str(group["groupId"]))
            groupArraySting = ",".join(groupArray)
        else:
            log.TestLog(u"企业下没有群组，请添加群组...")

        response = FormHttpPostFirst_returnData('http://' + serverIP + '/company/companyMemberAddPage_organizeTree.do',{})
        departmentId = response["data"][0]["id"]
        departmentName = response["data"][0]["name"].encode("utf-8")

    for i in range(int(startNum), int(endNum)+1):
        addStatus = False

        imei = int(imeiAssemble(companyCode)) + i*10000000000
        userCode = companyCode + str(i)
        userName = ""
        if (len(userCode) <= 3):
            userName = userCode + str(i)
        else:
            userName = userCode[0:3] + str(i)

        data    = {"userCode": userCode, 'userName': userName, 'userType': userType, 'sex': '0', 'imei': str(imei),'mobile': '18758038709', 'status': '1', 'groupIds': groupArraySting, 'defaultGroupId': defaultGroup, 'level':'100', 'permissions': '{5},{4},{3},{2},{1}',"departmentId":departmentId,"departmentName":departmentName}
        startTime_2 = time.time()
        response= FormHttpPost('http://'+serverIP+'/company/companyMemberAddPage_companyMemberAdd.do', data)
        if response == 100:
            log.TestLog(u"账号创建成功!")
            addStatus = True
        else:
            pass
            log.TestLog(u"账号创建失败!")
        endTime_2   = time.time()
        useTime_2   = endTime_2 - startTime_2

def PT_company_deleteUser_single(companyAccount, companyPassword, name, startNum, endNum):
    log.TestLog(u"开始批量删除企业用户...")
    lock = threading.Lock()

    username = companyAccount
    password = companyPassword
    loginStatus = False
    serverIP = '114.55.176.184'
    #serverIP = self.cpu["data"]._const["HTTP"]["HOST"]
    #serverIP = '114.55.63.81'

    url = 'http://'+serverIP+'/company/login.do'
    data = {'adminCode': username, 'password': password}
    # 登录后cookie的信息存储，用于携带cookie信息到服务端，然后服务端会在cookie中存入JSESSIONID并返回
    cookies = cookielib.CookieJar()
    cookies.set_cookie(make_cookie("fnRemeberAdminCode", "true", serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminCode", username, serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminPassword", password, serverIP+'/company/'))
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
    urllib2.install_opener(opener)
    # 发起登录请求
    startTime_1 = time.time()
    response = pressure_formHttpPost(url, data)
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 100:
        if lock.acquire():
            log.info(u"账号：" + username + u"\t 密码：" + password + u"\t登录成功!\t消耗时间：" + str(useTime_1) + "(s)")
            lock.release()
    for i in range(startNum, endNum + 1):
        userCode = name + str(i)
        url = 'http://'+serverIP+'/company/companyMemberEditPage.do?timeStamp=' + str(getTimestamp())
        data = {}
        editUserId = 0
        # 发起搜索ID请求
        startTime_2 = time.time()
        jsonAck = PageIdSearch(url, data, userCode)
        endTime_2 = time.time()
        useTime_2 = endTime_2 - startTime_2
        if jsonAck["status"] != -1 and jsonAck["id"] != 0:
            editUserId = jsonAck["id"]
            if lock.acquire():
                log.info(u"搜索账号" + userCode + u"成功，账号ID：" + str(editUserId) + u"\t消耗时间" + str(useTime_2))
                lock.release()
        else:
            if lock.acquire():
                log.info(u"搜索账号" + userCode + u"失败!" + u"\t消耗时间" + str(useTime_2))
                lock.release()
            continue

        # 删除对应ID所对应的账户信息
        startTime_3 = time.time()
        url = 'http://'+serverIP+'/company/companyMemberDel.do?id=' + editUserId
        data = {}
        response = pressure_formHttpDelete(url, data)
        endTime_3 = time.time()
        useTime_3 = endTime_3 - startTime_3
        if response["status"] == 100:
            if lock.acquire():
                log.info(u"删除账号" + userCode + u"成功!" + u"\t消耗时间" + str(useTime_3))
                lock.release()

# 创建企业群组
def PT_comapny_createGroup(cpu, companyAccount, companyPassword, groupCode, num):
    serverIP = cpu["data"]._const["HTTP"]["HOST"]
    # 登录后cookie的信息存储，用于携带cookie信息到服务端，然后服务端会在cookie中存入JSESSIONID并返回
    cookies     = cookielib.CookieJar()
    cookies.set_cookie(make_cookie("fnRemeberAdminCode", "true", serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminCode", companyAccount, serverIP+'/company/'))
    cookies.set_cookie(make_cookie("fnAdminPassword",  companyPassword, serverIP+'/company/'))
    opener      = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
    urllib2.install_opener(opener)

    # 发起登录请求
    response    = FormHttpPostFirst_returnData('http://'+serverIP+'/company/login.do', {'adminCode': companyAccount, 'password': companyPassword})
    if response["status"] == 100:
        log.info("Login success...")
        for i in range(1, int(num)+1):
            groupName = groupCode.encode("utf-8") + str(i)
            jsonAck = FormHttpPostFirst_returnData('http://' + serverIP + '/company/companyGroupAddPage_companyGroupAdd.do', {"groupName": groupName,"status":1})
            log.TestLog(str(jsonAck))
            if jsonAck["status"] == 100:
                log.TestLog(u"群组创建成功! 群组名为："+groupName.decode("utf-8"))
            elif jsonAck["status"] == 0:
                log.TestLog(jsonAck["error"])
            else:
                pass

# 测试平台：运营管理平台
# 调用方式：多线程
# 测试接口：创建用户、删除用户
# 创建用户流程# step1:企业账号登录 step2:增加用户
# 删除用户流程# Step1:企业账号登录 Step2:请求账号列表界面，过滤出对应ID step3:调用接口删除对应ID对应的用户
def PT_company_createUser_parallel(companyAccount, companyPassword, name, num):
    log.TestLog(u"开始批量创建企业用户...")
    thread_maxNum = num / 2
    lock = threading.Lock()
    #thread_PT_createUser_create(companyAccount, companyPassword, name, 10001, 10000+thread_maxNum, lock)
    #thread_PT_createUser_create(companyAccount, companyPassword, name, 10000 + thread_maxNum, 10000+num+1, lock)
    thread_PT_createUser_create(companyAccount, companyPassword, name, 10001, 10000+thread_maxNum, lock)
    thread_PT_createUser_create(companyAccount, companyPassword, name, 10000 + thread_maxNum, 10000+num+1, lock)

def PT_company_deleteUser_parallel(companyAccount, companyPassword, name, num):
    log.TestLog(u"开始批量删除企业用户...")
    thread_maxNum = num / 2
    lock = threading.Lock()
    thread_PT_deleteUser_create(companyAccount, companyPassword, name, 10001, 10000+thread_maxNum, lock)
    thread_PT_deleteUser_create(companyAccount, companyPassword, name, 10000 + thread_maxNum, 10000+num+1, lock)

# 测试平台：app服务端
# 调用方式：多线程
# 测试接口：HTTP登录接口、获取群组信息接口
# HTTP登录接口# step1:创建多线程 step2：每个线程进行登录，登录成功后将全局计数加1，处理完成后输出成功计数
# HTTP获取所有群组与成员信息# step1:创建多线程 step2:每个线程进行登录，登录成功后进入下一步 step3:发起获取所有群组与成员信息的请求，请求成功后将全局计数加1，处理完成后输出处理完成后输出成功计数
def PT_intercom_httpSoftwareQuery(cpu, num):
    log.TestLog(u"开始对软件更新接口进行压测...")
    cpu["data"]._const["PressureTest"]["softwareQuery"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_softwareQuery"] = 0
    lock = threading.Lock()
    for i in range(0, num):
        thread_PT_intercom_httpSoftwareQuery_create(cpu, num, lock)

def PT_intercom_httpLogin(cpu, username, password, startNum, endNum):
    log.TestLog(u"开始对HTTP登录接口进行压测...")
    cpu["data"]._const["PressureTest"]["loginNum"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_httpLogin"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_httpLogin"] = 0
    lock = threading.Lock()
    for i in range(startNum, endNum+1):
        thread_PT_intercom_httpLogin_create(cpu, username, password, i, lock)

def PT_intercom_httpGroupQuery(cpu, name, password, startNum, endNum):
    log.TestLog(u"开始对群组查询接口进行压测...")
    cpu["data"]._const["PressureTest"]["groupQuery"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_getGroupMember"] = 0
    lock = threading.Lock()
    for i in range(startNum,endNum+1):
        thread_PT_intercom_httpGroupQuery(cpu, name, password, i, lock)

def PT_intercom_httpGetAllGroupMember(cpu, name, password, startNum, endNum):
    log.TestLog(u"开始对获取所有群组成员信息接口进行压测...")
    cpu["data"]._const["PressureTest"]["getGroupMemberNum"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_getGroupMember"] = 0
    lock = threading.Lock()
    for i in range(startNum,endNum+1):
        thread_PT_intercom_httpGetAllGroupMember(cpu, name, password, i, lock)

# 测试平台：tcpapp服务
# 调用方式：多线程
# 测试接口：TCP接入接口、TCP心跳接口、进入语音频道
# TCP进入语音频道# step1:创建多线程 step2:每个线程进行登录请求，登录成功后进入下一步 step3:发起获取所有群组与成员信息的请求 step4:发起TCP接入接口的请求 step5:建立TCP心跳线程 step6:发起进入群组的请求
def PT_intercom_inVoiceChannel(cpu, name, password, startNum, endNum):
    log.TestLog(u"开始对进入语音频道接口进行压测...")
    cpu["data"]._const["PressureTest"]["inChannelNum"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_tcpIn"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_heart"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_heart"] = 0
    cpu["data"]._const["PressureTest"]["timeMin_inChannel"] = 0
    cpu["data"]._const["PressureTest"]["timeMax_inChannel"] = 0
    lock = threading.Lock()
    for i in range(startNum,endNum+1):
        thread_PT_intercom_inVoiceChannel(cpu, name, password, i, lock)

# 测试平台：tcpapp服务
# 调用方式：多线程，分批次
# 涉及接口：TCP接入接口、TCP心跳接口、进入语音频道接口
# TCP进入语音频道# step1：创建多线程 step2：每个线程进行登录请求，登录成功后进入下一步 step3：发起获取所有群组誉城苑信息的请求 step4：发起TCP接入的请求 step5建立TCP心跳线程 step6：发起进入群组的请求
def PT_getOnlineNumMax(cpu, name, password, num):
    log.TestLog(u"开始对进入语音频道接口进行压测...")
    cpu["data"]._const["PressureTest"]["onlineNumMax"] = 0
    lock = threading.Lock()

    for i in range(0, num%100):
        for j in range(10000+100*i, 10000+100*(i+1)):
            thread_PT_getOnlineNumMax(cpu, name, password, j, lock)
        time.sleep(10)

# 线程说明：创建压力测试线程的函数
# 测试接口：创建用户、删除用户、HTTP登录、获取所有群组与成员信息、进入群组通道
def thread_PT_createUser_create(companyAccount, companyPassword, name, startNum, endNum, lock):
    try:
        thread_PT_createUser = threading.Thread(target=createUserBatch, args=(companyAccount, companyPassword, name, startNum, endNum, lock,))
        thread_PT_createUser.start()
    except Exception, e:
        log.error("Error is occur in createUser:" + str(e))

def thread_PT_deleteUser_create(companyAccount, companyPassword, name, startNum, endNum, lock):
    try:
        thread_PT_createUser = threading.Thread(target=deleteUserBatch, args=(companyAccount, companyPassword, name, startNum, endNum, lock,))
        thread_PT_createUser.start()
    except Exception, e:
        log.error("Error is occur in deleteUser:" + str(e))

def thread_PT_intercom_httpSoftwareQuery_create(cpu, index, lock):
    try:
        thread_PT_intercom_httpSoftwareQuery = threading.Thread(target=intercom_httpSoftwareQuery, args=(cpu, index, lock,))
        thread_PT_intercom_httpSoftwareQuery.start()
    except Exception, e:
        log.error("Error is occur in httpLogin:" + str(e))

def thread_PT_intercom_httpLogin_create(cpu, username, password, index, lock):
    try:
        thread_PT_intercom_httpLogin = threading.Thread(target=intercom_httpLogin, args=(cpu, username, password, index, lock,))
        thread_PT_intercom_httpLogin.start()
    except Exception, e:
        log.error("Error is occur in httpLogin:" + str(e))

def thread_PT_intercom_httpGroupQuery(cpu, name, password, index, lock):
    try:
        thread_PT_intercom_httpGroupQuery = threading.Thread(target=intercom_httpGroupQuery, args=(cpu, name, password, index, lock,))
        thread_PT_intercom_httpGroupQuery.start()
    except Exception, e:
        log.error("Error is occur in httpGetAllGroupMember:" + str(e))

def thread_PT_intercom_httpGetAllGroupMember(cpu, name, password, index, lock):
    try:
        thread_PT_intercom_httpGetAllGroupMember = threading.Thread(target=intercom_httpGetAllGroupMember, args=(cpu, name, password, index, lock,))
        thread_PT_intercom_httpGetAllGroupMember.start()
    except Exception, e:
        log.error("Error is occur in httpGetAllGroupMember:" + str(e))

def thread_PT_intercom_inVoiceChannel(cpu, name, password, index, lock):
    try:
        thread_PT_intercom_inVoiceChannel = threading.Thread(target=intercom_inVoiceChannel, args=(cpu, name, password, index, lock,))
        thread_PT_intercom_inVoiceChannel.start()
    except Exception, e:
        log.error("Error is occur in inVoiceChannel" + str(e))

def thread_PT_getOnlineNumMax(cpu, name, password, index, lock):
    try:
        thread_PT_getOnlineNumMax = threading.Thread(target=intercom_getOnlineNumMax, args=(cpu, name, password, index, lock,))
        thread_PT_getOnlineNumMax.start()
    except Exception, e:
        log.error("Error is occur in getOnlineNumMax" + str(e))

# 函数说明：对应压测线程所调用的函数
# 测试接口：创建用户、删除用户、HTTP登录、获取所有群组与成员信息、进入语音频道
def createUserBatch(companyAccount, companyPassword, name, startNum, endNum, lock):
    for i in range(startNum, endNum):
        createUser(companyAccount, companyPassword, name, i, lock)

def deleteUserBatch(companyAccount, companyPassword, name, startNum, endNum, lock):
    for i in range(startNum, endNum):
        deleteUser(companyAccount, companyPassword, name, i, lock)

def createUser(companyAccount, companyPassword, name, index, lock):
    username = companyAccount
    password = companyPassword
    loginStatus = False
    nextflag = 0
    url = 'http://114.55.176.184/company/login.do'
    data = {'adminCode': username, 'password': password}
    # 登录后cookie的信息存储，用于携带cookie信息到服务端，然后服务端会在cookie中存入JSESSIONID并返回
    cookies = cookielib.CookieJar()
    cookies.set_cookie(make_cookie("fnRemeberAdminCode", "true", '114.55.176.184/company/'))
    cookies.set_cookie(make_cookie("fnAdminCode", username, '114.55.176.184/company/'))
    cookies.set_cookie(make_cookie("fnAdminPassword", password, '114.55.176.184/company/'))
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
    urllib2.install_opener(opener)
    # 发起登录请求
    startTime_1 = time.time()
    response = pressure_formHttpPost(url, data)
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 100:
        nextflag = 1
        if lock.acquire():
            log.TestLog(u"账号：" + username + u"\t密码：" + password + u"\t登录成功!\t消耗的时间：" + str(useTime_1))
            lock.release()
    if nextflag == 1:
        addStatus = False
        userCode = name + str(index)
        userName = name + str(index)
        url = 'http://114.55.176.184/company/companyMemberAddPage_companyMemberAdd.do'
        #data = {"userCode": userCode, 'userName': userName, 'userType': '1', 'sex': '0', 'imei': '','mobile': '18758038709', 'status': '1','groupIds': '5294,5295,5296,5297,5298,5299,5300,5301,5302,5303,5305,5306,5307,5308,5309,5341,5342,5343,5344,5345','defaultGroupId': '5295', 'permissions': '{5},{4},{3},{2},{1}'}
        data = {"userCode": userCode, 'userName': userName, 'userType': '1', 'sex': '0', 'imei': '','mobile': '18758038709', 'status': '1','groupIds': '4543,4544,4545,4555,4558,4559,4561,4562,4564,4569','defaultGroupId': '5295', 'permissions': '{5},{4},{3},{2},{1}'}
        startTime_2 = time.time()
        response = pressure_formHttpPost(url, data)
        if response["status"] == 100:
            addStatus = True
        endTime_2 = time.time()
        useTime_2 = endTime_2 - startTime_2
        if lock.acquire():
            log.TestLog(u"创建用户" + userCode + u"的状态：" + str(addStatus) + u"\t消耗时间：" + str(useTime_2) + "(s)")
            lock.release()

def deleteUser(companyAccount, companyPassword, name, index, lock):
    time.sleep(random.uniform(0,2))
    username = companyAccount
    password = companyPassword
    userCode = name + str(index)
    loginStatus = False
    nextflag = 0
    editUserId = 0
    url = 'http://114.55.176.184/company/login.do'
    data = {'adminCode': username, 'password': password}
    # 登录后cookie的信息存储，用于携带cookie信息到服务端，然后服务端会在cookie中存入JSESSIONID并返回
    cookies = cookielib.CookieJar()
    cookies.set_cookie(make_cookie("fnRemeberAdminCode", "true", '114.55.176.184/company/'))
    cookies.set_cookie(make_cookie("fnAdminCode", username, '114.55.176.184/company/'))
    cookies.set_cookie(make_cookie("fnAdminPassword", password, '114.55.176.184/company/'))
    opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies))
    urllib2.install_opener(opener)
    # 发起登录请求
    startTime_1 = time.time()
    response = pressure_formHttpPost(url, data)
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 100:
        nextflag = 1
        if lock.acquire():
            log.TestLog(u"账号：" + username + u"\t 密码：" + password + u"\t登录成功!\t消耗时间：" + str(useTime_1) + "(s)")
            lock.release()
    if nextflag == 1:
        url = 'http://114.55.176.184/company/companyMemberEditPage.do?timeStamp=' + str(getTimestamp())
        data = {}
        # 发起搜索ID请求
        startTime_2 = time.time()
        nextflag = 0
        jsonAck = PageIdSearch(url, data, userCode)
        endTime_2 = time.time()
        useTime_2 = endTime_2 - startTime_2
        if jsonAck["status"] != -1 and jsonAck["id"] != 0:
            editUserId = jsonAck["id"]
            nextflag = 1
            if lock.acquire():
                log.TestLog(u"搜索账号" + userCode + u"成功，账号ID：" + str(editUserId) + u"\t消耗时间" + str(useTime_2))
                lock.release()
        else:
            if lock.acquire():
                log.TestLog(u"搜索账号" + userCode + u"失败!" + u"\t消耗时间" + str(useTime_2))
                lock.release()

    # 删除对应ID所对应的账户信息
    if nextflag == 1:
        startTime_3 = time.time()
        url = 'http://114.55.176.184/company/companyMemberDel.do?id=' + editUserId
        data = {}
        response = pressure_formHttpDelete(url, data)
        endTime_3 = time.time()
        useTime_3 = endTime_3 - startTime_3
        if response["status"] == 100:
            if lock.acquire():
                log.TestLog(u"删除账号" + userCode + u"成功!" + u"\t消耗时间" + str(useTime_3))
                lock.release()

def intercom_httpSoftwareQuery(cpu, index, lock):
    imei = 358740055952492 + 8 * index
    startTime_1 = time.time()
    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/softwareQuery.do',getSoftwareQuery('20',str(imei),'T1W-01'))
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 'success' and response["content"]["status"] == 1000:
        if lock.acquire():
            log.TestLog(u"软件更新返回正确，消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()
        if lock.acquire():
            cpu["data"]._const["PressureTest"]["softwareQuery"] += 1
            log.TestLog(u"当前成功登录的账号数为：" + str(cpu["data"]._const["PressureTest"]["softwareQuery"]))
            lock.release()
    else:
        if lock.acquire():
            log.TestLog(u"软件更新返回失败，消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()

    if cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"] == 0:
        cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"] = useTime_1
    elif useTime_1 < cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"]:
        cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"] = useTime_1
    if useTime_1 > cpu["data"]._const["PressureTest"]["timeMax_softwareQuery"]:
        cpu["data"]._const["PressureTest"]["timeMax_softwareQuery"] = useTime_1

    if lock.acquire():
        log.TestLog(u"版本更新时间：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_softwareQuery"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_softwareQuery"]))
        lock.release()

def intercom_httpLogin(cpu, name, password, index, lock):
    username = name + str(index)
    startTime_1 = time.time()
    #response = pressure_fnHttpPost_app('120.27.201.238', 80, '/fn/app/login.do', getLoginMsg(username, password, 1))
    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/login.do', getLoginMsg(username, password, 1))
    #response = pressure_fnHttpPost_app('120.27.202.5', 80, '/fn/app/login.do', getLoginMsg(username, password, 1))
    #response = pressure_fnHttpPost_app('120.27.202.5', 80, '/fn/app/login.do', getLoginMsg("aoTest10020", "123456", 1))

    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 'success' and response["content"]["status"] == 1000:
        if lock.acquire():
            log.TestLog(u"账号登录成功，账号为：" + username + u"\t消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()
        if lock.acquire():
            cpu["data"]._const["PressureTest"]["loginNum"] += 1
            log.TestLog(u"当前成功登录的账号数为：" + str(cpu["data"]._const["PressureTest"]["loginNum"]))
            lock.release()
    else:
        if lock.acquire():
            log.TestLog(u"账号登录失败，账号为：" + username + u"\t消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()
    if cpu["data"]._const["PressureTest"]["timeMin_httpLogin"] == 0:
        cpu["data"]._const["PressureTest"]["timeMin_httpLogin"] = useTime_1
    elif useTime_1 < cpu["data"]._const["PressureTest"]["timeMin_httpLogin"]:
        cpu["data"]._const["PressureTest"]["timeMin_httpLogin"] = useTime_1
    if useTime_1 > cpu["data"]._const["PressureTest"]["timeMax_httpLogin"]:
        cpu["data"]._const["PressureTest"]["timeMax_httpLogin"] = useTime_1

    if lock.acquire():
        log.TestLog(u"HTTP登录时间：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_httpLogin"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_httpLogin"]))
        lock.release()

def intercom_httpGroupQuery(cpu, name, password, index, lock):
    username = name + str(index)
    nextflag = 0
    userType = 2
    uid = 0
    cmpid = 0
    key = 0
    #loginStatus = False
    startTime_1 = time.time()

    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/login.do', getLoginMsg(username, password, userType))
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 'success'  and response["content"]["status"] == 1000:
        nextflag = 1
        uid = response["content"]["body"]["userid"]
        cmpid = response["content"]["body"]["companyId"]
        key = response["content"]["body"]["userToken"]
    else:
        if lock.acquire():
            log.TestLog(u"账号登录失败，账号为：" + username + u"\t消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()
        return
    if nextflag == 1:
        startTime_2 = time.time()
        response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupQuery.do', getGroupQueryMsg(uid, cmpid, userType, '', key))

        endTime_2 = time.time()
        useTime_2 = endTime_2 - startTime_2
        if response["status"] == 'success'  and response["content"]["status"] == 1000:
            if lock.acquire():
                log.TestLog(u"群组及成员信息拉取成功，账号为：" + username + u"\t消耗时间为：" + str(useTime_2) + u"\t接收内容为：" + str(response["content"]))
                lock.release()
            if lock.acquire():
                cpu["data"]._const["PressureTest"]["groupQuery"] += 1
                log.TestLog(u"当前成功拉取群组成员信息的账号数为：" + str(cpu["data"]._const["PressureTest"]["groupQuery"]))
                lock.release()
        else:
            if lock.acquire():
                log.TestLog(u"群组及成员信息拉取失败，账号为：" + username + u"\t消耗时间为：" + str(useTime_2) + u"\t接收内容为：" + str(response["content"]))
                #log.TestLog("uid:"+str(uid)+"\tcmpid:"+str(cmpid)+"\tuserType:"+str(userType))
                #log.info(str(response["content"]["error"]["message"].encode("utf-8")))
                lock.release()
        if cpu["data"]._const["PressureTest"]["timeMin_groupQuery"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_groupQuery"] = useTime_2
        elif useTime_2 < cpu["data"]._const["PressureTest"]["timeMin_groupQuery"]:
            cpu["data"]._const["PressureTest"]["timeMax_groupQuery"] = useTime_2
        if useTime_2 > cpu["data"]._const["PressureTest"]["timeMax_groupQuery"]:
            cpu["data"]._const["PressureTest"]["timeMax_groupQuery"] = useTime_2

        if lock.acquire():
            log.TestLog(u"拉群群组时间：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_groupQuery"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_groupQuery"]))
            lock.release()

def intercom_httpGetAllGroupMember(cpu, name, password, index, lock):
    username = name + str(index)
    nextflag = 0
    userType = 2
    uid = 0
    cmpid = 0
    key = 0
    #loginStatus = False
    startTime_1 = time.time()

    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/login.do', getLoginMsg(username, password, userType))
    endTime_1 = time.time()
    useTime_1 = endTime_1 - startTime_1
    if response["status"] == 'success' and response["content"]["status"] == 1000:
        nextflag = 1
        uid = response["content"]["body"]["userid"]
        cmpid = response["content"]["body"]["companyId"]
        key = response["content"]["body"]["userToken"]
    else:
        if lock.acquire():
            log.TestLog(u"账号登录失败，账号为：" + username + u"\t消耗时间为：" + str(useTime_1) + u"\t接收内容为：" + str(response["content"]))
            lock.release()
        return
    if nextflag == 1:
        startTime_2 = time.time()
        response = pressure_fnHttpPost(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupMemberLocationsQuery.do', getGroupMemberLocationsQueryMsg(uid, userType, cmpid, key))
        #response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupQuery.do', getGroupQueryMsg(uid, cmpid, userType, '', key))
        endTime_2 = time.time()
        useTime_2 = endTime_2 - startTime_2
        if response["status"] == 'success':
            if lock.acquire():
                log.TestLog(u"群组及成员信息拉取成功，账号为：" + username + u"\t消耗时间为：" + str(useTime_2))
                lock.release()
            if lock.acquire():
                cpu["data"]._const["PressureTest"]["getGroupMemberNum"] += 1
                log.TestLog(u"当前成功拉取群组成员信息的账号数为：" + str(cpu["data"]._const["PressureTest"]["getGroupMemberNum"]))
                lock.release()
        else:
            if lock.acquire():
                log.TestLog(u"群组及成员信息拉取失败，账号为：" + username + u"\t消耗时间为：" + str(useTime_2) + u"\t接收内容为：" + str(response["content"]))
                lock.release()
        if cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"] = useTime_2
        elif useTime_2 < cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"]:
            cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"] = useTime_2
        if useTime_2 > cpu["data"]._const["PressureTest"]["timeMax_getGroupMember"]:
            cpu["data"]._const["PressureTest"]["timeMax_getGroupMember"] = useTime_2

        if lock.acquire():
            log.TestLog(u"拉群群组时间：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_getGroupMember"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_getGroupMember"]))
            lock.release()

def intercom_inVoiceChannel(cpu, name, password, index, lock):
    username = name+str(index)
    userType = 2
    FN_KEY = 'AZ-FN-CODEC-KEY'
    uid = 0
    gid = 4544
    cmpid = 0
    key = ''
    nextflag = 0
    useTime = 0
    startTime_all = time.time()
    # 发送HTTP登录的请求
    startTime_httpLogin = time.time()
    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/login.do', getLoginMsg(username, password, userType))
    endTime_httpLogin = time.time()
    useTime_httpLogin = endTime_httpLogin - startTime_httpLogin
    if response["status"] == 'success' and response["content"]["status"] == 1000:
        uid = response["content"]["body"]["userid"]
        cmpid = response["content"]["body"]["companyId"]
        key = response["content"]["body"]["userToken"]
        cpu[uid] = {}
        cpu[uid]["cmpid"] = cmpid
        cpu[uid]["key"] = key
        cpu[uid]["token"] = None
        cpu[uid]["cid"] = None
        cpu[uid]["sid"] = None
        cpu[uid]["aip"] = None
        cpu[uid]["aport"] = None
        cpu[uid]["stat"] = None
        nextflag = 1

    if nextflag == 1:
        #log.info(u"发送HTTP获取群组成员信息的请求")
        startTime_getGroupMember = time.time()
        #response = pressure_fnHttpPost(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupMemberLocationsQuery.do', getGroupMemberLocationsQueryMsg(uid, userType, cmpid, key))
        response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupQuery.do', getGroupQueryMsg(uid, cmpid, userType, '', key))
        endTime_getGroupMember = time.time()
        useTime_getGroupMember = endTime_getGroupMember - startTime_getGroupMember

        #log.info(u"开始建立Websocket来进行TCP通信")
        websocket = pressure_webSocket(cpu, cpu["data"]._const["WS"]["CONFIG"]["HOST"], 8087, 'fn-ws', cmpid, uid, password, key)
        #log.info(u"发起TCP接入请求1——>8001")
        times = 0
        while True:
            if(websocket.statCon == True):
                websocket.startTime_tcpIn = time.time()
                websocket.wsTcpSend(assemblyTCPData(1, 1, 1, getAccessMsg(cmpid, uid, md5(password), userType, FN_KEY)))
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)
        #log.info(u"发起心跳信息2——>8002")
        times = 0
        while True:
            if(websocket.statTcpIn == True):
                websocket.startTime_heart = time.time()
                websocket.wsTcpSend(assemblyTCPData(2, 1, 0, getHeartBeatMsg(cmpid, uid, websocket.token)))
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)
        #log.info(u"创建心跳线程2——>8002")
        thread_heartbeat = threading.Thread(target=heartbeat, args=(websocket, cmpid, uid, websocket.token))
        thread_heartbeat.start()

        #log.info(u"发起进入群组的请求3——>8003")
        times = 0
        while True:
            if(websocket.statHeart == True):
                websocket.startTIme_inChannel = time.time()
                websocket.wsTcpSend(assemblyTCPData(3, 1, 1, getInVoiceChannelMsg(cmpid, uid, gid, cpu["data"]._const["CHANNEL_TYPE"]["intercom"])))
                break
            else:
                if times > 5000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)

        times = 0
        while True:
            if(websocket.statInChannel == True):
                websocket.gid = gid
                if lock.acquire():
                    cpu["data"]._const["PressureTest"]["inChannelNum"] += 1
                    log.TestLog(u"进入语音频道的数量：" + str(cpu["data"]._const["PressureTest"]["inChannelNum"]))
                    lock.release()
                websocket.endTime_inChannel = time.time()
                endTime_all = time.time()
                useTime_all = endTime_all - startTime_all
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)

        time.sleep(5)
        websocket.wsTcpSend(assemblyTCPData(4, 1, 1, getOutVoiceChannelMsg(cmpid, uid)))

        #log.info(u"耗时计算")
        useTime_creatWS = websocket.endTime_init - websocket.startTime_init
        useTime_tcpIn = websocket.endTime_tcpIn - websocket.startTime_tcpIn
        useTime_heart = websocket.endTime_heart - websocket.startTime_heart
        useTime_inChannel = websocket.endTime_inChannel - websocket.startTIme_inChannel

        if lock.acquire():
            log.TestLog(u"HTTP登录耗时："+str(useTime_httpLogin)+
                     u"\tHTTP获取群组与成员信息耗时："+str(useTime_getGroupMember)+
                     u"\t  创建Websocket耗时："+str(useTime_creatWS)+
                     u"\tTCP接入状态："+str(websocket.statTcpIn)+
                     u"\tTCP接入耗时："+str(useTime_tcpIn)+
                     u"\tTCP心跳状态："+str(websocket.statHeart)+
                     u"\tTCP心跳耗时："+str(useTime_heart)+
                     u"\tTCP语音状态："+str(websocket.statInChannel)+
                     u"\tTCP进入语音频道："+str(useTime_inChannel)+
                     u"\t进入语音频道总耗时："+str(useTime_all))
            lock.release()
        if cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] = useTime_tcpIn
        elif useTime_tcpIn < cpu["data"]._const["PressureTest"]["timeMin_tcpIn"]:
            cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] = useTime_tcpIn
        if useTime_tcpIn > cpu["data"]._const["PressureTest"]["timeMax_tcpIn"]:
            cpu["data"]._const["PressureTest"]["timeMax_tcpIn"] = useTime_tcpIn

        if cpu["data"]._const["PressureTest"]["timeMin_heart"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_heart"] =useTime_heart
        elif useTime_heart < cpu["data"]._const["PressureTest"]["timeMin_heart"]:
            cpu["data"]._const["PressureTest"]["timeMin_heart"] = useTime_heart
        if useTime_heart > cpu["data"]._const["PressureTest"]["timeMax_heart"]:
            cpu["data"]._const["PressureTest"]["timeMax_heart"] = useTime_heart

        if cpu["data"]._const["PressureTest"]["timeMin_inChannel"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_inChannel"] = useTime_inChannel
        elif useTime_inChannel < cpu["data"]._const["PressureTest"]["timeMin_inChannel"]:
            cpu["data"]._const["PressureTest"]["timeMin_inChannel"] = useTime_inChannel
        if useTime_inChannel > cpu["data"]._const["PressureTest"]["timeMax_inChannel"]:
            cpu["data"]._const["PressureTest"]["timeMax_inChannel"] = useTime_inChannel

        if lock.acquire():
            log.TestLog(u"TCP接入：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_tcpIn"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_tcpIn"]))
            log.TestLog(u"TCP心跳：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_heart"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_heart"]))
            log.TestLog(u"进入语音频道：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_inChannel"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_inChannel"]))
            lock.release()

def intercom_getOnlineNumMax(cpu, name, password, index, lock):
    username = name+str(index)
    userType = 3
    FN_KEY = 'AZ-FN-CODEC-KEY'
    uid = 0
    gid = 4544
    cmpid = 0
    key = ''
    nextflag = 0
    useTime = 0
    startTime_all = time.time()
    # 发送HTTP登录的请求
    startTime_httpLogin = time.time()
    response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/login.do', getLoginMsg(username, password, userType))
    endTime_httpLogin = time.time()
    useTime_httpLogin = endTime_httpLogin - startTime_httpLogin
    if response["status"] == 'success' and response["content"]["status"] == 1000:
        uid = response["content"]["body"]["userid"]
        cmpid = response["content"]["body"]["companyId"]
        key = response["content"]["body"]["userToken"]
        cpu[uid] = {}
        cpu[uid]["cmpid"] = cmpid
        cpu[uid]["key"] = key
        cpu[uid]["token"] = None
        cpu[uid]["cid"] = None
        cpu[uid]["sid"] = None
        cpu[uid]["aip"] = None
        cpu[uid]["aport"] = None
        cpu[uid]["stat"] = None
        nextflag = 1

    if nextflag == 1:
        #log.info(u"发送HTTP获取群组成员信息的请求")
        startTime_getGroupMember = time.time()
        #response = pressure_fnHttpPost(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupMemberLocationsQuery.do', getGroupMemberLocationsQueryMsg(uid, userType, cmpid, key))
        response = pressure_fnHttpPost_app(cpu["data"]._const["WS"]["CONFIG"]["HOST"], 80, '/fn/app/groupQuery.do', getGroupQueryMsg(uid, cmpid, userType, '', key))
        endTime_getGroupMember = time.time()
        useTime_getGroupMember = endTime_getGroupMember - startTime_getGroupMember

        #log.info(u"开始建立Websocket来进行TCP通信")
        websocket = pressure_webSocket(cpu, cpu["data"]._const["WS"]["CONFIG"]["HOST"], 8087, 'fn-ws', cmpid, uid, password, key)
        #log.info(u"发起TCP接入请求1——>8001")
        times = 0
        while True:
            if(websocket.statCon == True):
                websocket.startTime_tcpIn = time.time()
                websocket.wsTcpSend(assemblyTCPData(1, 1, 1, getAccessMsg(cmpid, uid, md5(password), userType, FN_KEY)))
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)
        #log.info(u"发起心跳信息2——>8002")
        times = 0
        while True:
            if(websocket.statTcpIn == True):
                websocket.startTime_heart = time.time()
                websocket.wsTcpSend(assemblyTCPData(2, 1, 0, getHeartBeatMsg(cmpid, uid, websocket.token)))
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)
        #log.info(u"创建心跳线程2——>8002")
        thread_heartbeat = threading.Thread(target=heartbeat, args=(websocket, cmpid, uid, websocket.token))
        thread_heartbeat.start()

        #log.info(u"发起进入群组的请求3——>8003")
        times = 0
        while True:
            if(websocket.statHeart == True):
                websocket.startTIme_inChannel = time.time()
                websocket.wsTcpSend(assemblyTCPData(3, 1, 1, getInVoiceChannelMsg(cmpid, uid, gid, cpu["data"]._const["CHANNEL_TYPE"]["intercom"])))
                break
            else:
                if times > 5000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)

        times = 0
        while True:
            if(websocket.statInChannel == True):
                if lock.acquire():
                    cpu["data"]._const["PressureTest"]["onlineNumMax"] += 1
                    log.TestLog(u"对讲终端同时在线数量：" + str(cpu["data"]._const["PressureTest"]["onlineNumMax"]))
                    lock.release()
                websocket.endTime_inChannel = time.time()
                endTime_all = time.time()
                useTime_all = endTime_all - startTime_all
                break
            else:
                if times > 2000:
                    return -1
                else:
                    times+=1
                time.sleep(0.001)

        #time.sleep(5)
        #websocket.wsTcpSend(assemblyTCPData(4, 1, 1, getOutVoiceChannelMsg(cmpid, uid)))

        #log.info(u"耗时计算")
        useTime_creatWS = websocket.endTime_init - websocket.startTime_init
        useTime_tcpIn = websocket.endTime_tcpIn - websocket.startTime_tcpIn
        useTime_heart = websocket.endTime_heart - websocket.startTime_heart
        useTime_inChannel = websocket.endTime_inChannel - websocket.startTIme_inChannel

        if lock.acquire():
            log.TestLog(u"HTTP登录耗时："+str(useTime_httpLogin)+
                     u"\tHTTP获取群组与成员信息耗时："+str(useTime_getGroupMember)+
                     u"\t  创建Websocket耗时："+str(useTime_creatWS)+
                     u"\tTCP接入状态："+str(websocket.statTcpIn)+
                     u"\tTCP接入耗时："+str(useTime_tcpIn)+
                     u"\tTCP心跳状态："+str(websocket.statHeart)+
                     u"\tTCP心跳耗时："+str(useTime_heart)+
                     u"\tTCP语音状态："+str(websocket.statInChannel)+
                     u"\tTCP进入语音频道："+str(useTime_inChannel)+
                     u"\t进入语音频道总耗时："+str(useTime_all))
            lock.release()
        if cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] = useTime_tcpIn
        elif useTime_tcpIn < cpu["data"]._const["PressureTest"]["timeMin_tcpIn"]:
            cpu["data"]._const["PressureTest"]["timeMin_tcpIn"] = useTime_tcpIn
        if useTime_tcpIn > cpu["data"]._const["PressureTest"]["timeMax_tcpIn"]:
            cpu["data"]._const["PressureTest"]["timeMax_tcpIn"] = useTime_tcpIn

        if cpu["data"]._const["PressureTest"]["timeMin_heart"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_heart"] =useTime_heart
        elif useTime_heart < cpu["data"]._const["PressureTest"]["timeMin_heart"]:
            cpu["data"]._const["PressureTest"]["timeMin_heart"] = useTime_heart
        if useTime_heart > cpu["data"]._const["PressureTest"]["timeMax_heart"]:
            cpu["data"]._const["PressureTest"]["timeMax_heart"] = useTime_heart

        if cpu["data"]._const["PressureTest"]["timeMin_inChannel"] == 0:
            cpu["data"]._const["PressureTest"]["timeMin_inChannel"] = useTime_inChannel
        elif useTime_inChannel < cpu["data"]._const["PressureTest"]["timeMin_inChannel"]:
            cpu["data"]._const["PressureTest"]["timeMin_inChannel"] = useTime_inChannel
        if useTime_inChannel > cpu["data"]._const["PressureTest"]["timeMax_inChannel"]:
            cpu["data"]._const["PressureTest"]["timeMax_inChannel"] = useTime_inChannel

        if lock.acquire():
            log.TestLog(u"TCP接入：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_tcpIn"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_tcpIn"]))
            log.TestLog(u"TCP心跳：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_heart"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_heart"]))
            log.TestLog(u"进入语音频道：\t" + str(cpu["data"]._const["PressureTest"]["timeMin_inChannel"]) + "-->" + str(cpu["data"]._const["PressureTest"]["timeMax_inChannel"]))
            lock.release()
